home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / basic / PureBasic_Upd.lha / PureBasic_Update1.60 / PureBasic / Examples / Sources / PopupMenu.pb < prev    next >
Encoding:
Text File  |  2000-09-10  |  1.9 KB  |  97 lines

  1.  
  2. ; ***************************************
  3. ;
  4. ;  PopupMenu example file for PureBasic
  5. ;
  6. ;      © 2000 - Fantaisie Software -
  7. ;
  8. ; ***************************************
  9.  
  10.  
  11. #Menu=0
  12. #WINDOW_FLAGS=#WFLG_DRAGBAR|#WFLG_CLOSEGADGET|#WFLG_RMBTRAP|#WFLG_ACTIVATE
  13. #IDCMP_FLAGS=#IDCMP_MOUSEBUTTONS|#IDCMP_CLOSEWINDOW|#IDCMP_VANILLAKEY
  14.  
  15.  
  16.  If InitWindow(0) AND InitPopupMenu(#Menu) AND InitTagList(20)         
  17.  
  18.    Title.s = "PopupMenu with Pure Basic."
  19.  
  20.    ResetTagList(#WA_Title , @Title)
  21.    AddTag(#WA_IDCMP, #IDCMP_FLAGS)
  22.  
  23.  
  24.    *w.Window = OpenWindow(0, 2, 12, 215, 40, #WINDOW_FLAGS, TagListID())
  25.  
  26.    If *w
  27.  
  28.      PopupMenuTitle("PopupMenu")
  29.  
  30.        PopupMenuCheckItem  (1, "Check1", "A")
  31.        PopupMenuItem       (2, "Item1",  "B")
  32.        PopupMenuSubMenuItem("SubMenu1")
  33.  
  34.          PopupMenuSubItem     (3, "SubItem1" , "C")
  35.          PopupMenuCheckSubItem(4, "SubCheck1", "")
  36.          PopupMenuSubBar()
  37.          PopupMenuSubInfo("SubInfo1")
  38.          PopupMenuSubBar()
  39.          PopupMenuSubItem(5, "SubItem2", "")
  40.  
  41.        PopupMenuBar()
  42.        PopupMenuInfo("Info1")
  43.        PopupMenuBar()
  44.        PopupMenuItem(6, "Quit", "")
  45.  
  46.      Error.w=AttachPopupMenu(#Menu, *w)
  47.  
  48.      If Error.w = 0
  49.  
  50.        loop.w=1
  51.  
  52.        Repeat
  53.  
  54.          PM_Event.l=WaitPopupMenuEvent(#Menu)
  55.  
  56.          Select PM_Event.l
  57.  
  58.           Case 1
  59.            If PopupMenuChecked(#Menu,1)
  60.              PrintN("Quit was Enabled.")
  61.            Else
  62.              PrintN("Quit was Disabled.")
  63.            EndIf
  64.  
  65.            s.w=1-s.w
  66.            If DisablePopupMenuItem(#Menu,6,s.w)
  67.              If s.w
  68.                PrintN("Quit is Disabled.")
  69.               Else
  70.                PrintN("Quit is Enabled.")
  71.               EndIf
  72.            EndIf
  73.  
  74.           Case 6
  75.            loop=0
  76.  
  77.           Case #IDCMP_CLOSEWINDOW
  78.            loop=0
  79.  
  80.           Default
  81.            Print("MenuItem=") : PrintNumberN(PM_Event.l)
  82.  
  83.          EndSelect
  84.  
  85.        Until loop = 0
  86.  
  87.        FreePopupMenu(#Menu)
  88.      EndIf
  89.  
  90.    EndIf
  91.  
  92.  EndIf
  93.  
  94.  PrintN("End of Program.")
  95.  End
  96.  
  97.